<template>
    <div class="body">
        <div style="padding-bottom: 20px">
            <b>欢迎你！{{ user.nickname }}</b>
        </div>
        <el-card v-for="item in newsList" :key="item.id" style="width: 100%;margin-bottom: 20px;"shadow="hover">
            <div class="block">
                <el-tag type="primary" class="tag">
                    {{item.newsType}}
                </el-tag>
                <div class="title">{{item.newsTitle}}</div>
                <div class="content">{{item.newsContent}}</div>
                <div class="time">{{item.createTime}}</div>
            </div>
        </el-card>
    
    </div>
</template>

<script>
export default {
    name: "Home",
    data() {
        return {
            user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {},
            newsList: [],
        }
    },
    created() {
        this.load();
    },
    methods: {
        load() {
            this.request.get("/news/").then(res => {
                this.newsList = res.data
                console.log('this.newsList', this.newsList);
            })
        }
    }
}
</script>
<style scoped>
.body{
    height: 500px;
    color: #666;
    font-size: 14px;
}
.time{
    font-weight: lighter;
    font-size: 10px;
    
}
.block{
    display: flow;
}
.content{

    width: 100%;
    margin-bottom: 20px;
}
.title{

    width: 100%;
    font-size: 16px;
    font-weight: bold;
}
.tag{
    float: left;
}
</style>